package collection;

import java.util.ArrayList;
import java.util.Collection;

public class CollectinoDemo01 {
    public static void main(String[] args) {
        Collection c = new ArrayList();
        c.add(new Point(1,2));
        c.add(new Point(3,4));
        c.add(new Point(5,6));
        c.add(new Point(7,8));
        c.add(new Point(9,0));
        c.add(new Point(1,2));
        System.out.println(c);

        /*
        * boolean contains(Object o);
        * 判断集合是否包含给定元素
        * 注意：contains 方法的判断依据是基于equals方法，会将给定元素o和当前集合中每一个元素进行equals比较
        * 有一个元素相同即为true
        * */
        Point p = new Point(1,2);
        boolean contains = c.contains(p);
        System.out.println(contains);

        /**
         * boolean remove(object o)
         * 从集合中删除给定元素，删除成功返回true
         * 当集合中存在多个需要删除的元素时，只能删除第一个且方法结束*/
        boolean remove = c.remove(p);
        System.out.println("是否删除："+remove);
        System.out.println(c);

    }
}
